package com.humanmonth.home.component.page.htree
{
	import com.humanmonth.util.effect.ClickGlowEffect;
	import com.humanmonth.util.effect.PassbyEffectScale;
	
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	import mx.core.Application;
	import mx.events.FlexEvent;
	import mx.managers.PopUpManager;
	
	public class ActionBarAs extends ActionBar
	{
		private  var whiteBoard:WhiteBoardAs;
		public function ActionBarAs()
		{
			super();
			this.addEventListener(FlexEvent.CREATION_COMPLETE,myInit);
		}
		
		private function myInit(event:Event):void{
			this.initEffect();
			this.initListener();
			whiteBoard=Application.application.hTree.whiteBoard;
		}
		
		private function initEffect():void{
			var scale:PassbyEffectScale=new PassbyEffectScale();
			scale.applyEffect(this.buStep);
			scale.applyEffect(this.buAction);
		    var glow:ClickGlowEffect=new ClickGlowEffect();
			glow.applyEffect(this.buStep);
			glow.applyEffect(this.buAction);				
		}
		
		private function initListener():void{
			this.buStep.addEventListener(MouseEvent.CLICK,popAddNode);
			this.buAction.addEventListener(MouseEvent.CLICK,popAddLine);
		}
		
		/**
		 * 弹出新建节点的窗口 
		 */
		private function popAddNode(event:Event):void{
			var nodeForm:NodeFormAs=NodeFormAs(	PopUpManager.createPopUp(whiteBoard,NodeFormAs,true));
			PopUpManager.centerPopUp(nodeForm);
		}
		
		/**
		 * 弹出增加线条的窗口 
		 */
		private function popAddLine(event:Event):void{
			var lineForm:MyLineFormAs=MyLineFormAs(PopUpManager.createPopUp(whiteBoard,MyLineFormAs,true));
			PopUpManager.centerPopUp(lineForm);
		}
		
	}
}